<?php
//各管理页面动作集成
class ManageAction extends Action {
	//院系专业管理页面动作集成

	//院系专业管理页面入口
    public function manageCollege(){
		$path=$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'];
		$path=substr($path,0,strlen($path)-9);
		$this->path=$path;
		$this->display();
	}
	//院系专业管理页面添加数据动作
	public function add(){
		$id=$_POST['id'];
		$name=$_POST['name'];
		$up=$_POST['up'];
		
		$tree=M('tree');
		$data['tree_id']=$id;
		$data['tree_name']=$name;
		$data['tree_up']=$up;
		$result=$tree->add($data);
		
		if($result){
			echo '{state:"ok"}';
		}else{
			echo '{state:"error"}';
		}
	}
	//院系专业管理页面修改数据动作
	public function update(){
		$id=$_POST['id'];
		$name=$_POST['name'];
		$up=$_POST['up'];
		
		$tree=M('tree');
		$data['tree_id']=$id;
		$data['tree_name']=$name;
		$data['tree_up']=$up;
		$result=$tree->save($data);
		
		if($result){
			echo '{state:"ok"}';
		}else{
			echo '{state:"error"}';
		}
	}
	//院系专业管理页面删除数据动作
	public function del(){
		$id=$_POST['id'];
		
		$tree=M('tree');
		$tree->where('tree_id='.$id);
		$result=$tree->delete();
		
		if($result){
			echo '{state:"ok"}';
		}else{
			echo '{state:"error"}';
		}
	}
	//院系专业管理页面获取目录动作
	public function getCollege(){
		$tree=M("tree");
		$result=$tree->query('select * from __TABLE__ order by tree_id asc');
		
		if($result){
			$arr['state']='ok';
			$arr['data']=$result;	
		}else{
			$arr['state']='error';	
		}
		
		echo json_encode($arr);
			
	}
	//******************************************************************************//
	//学生管理页面动作集成
	
	//学生管理入口
	public function manageStudent(){
		$path=$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'];
		$path=substr($path,0,strlen($path)-9);
		$this->path=$path;
		$this->display();
	}
	//
	public function studentAdd(){
		$data['sdt_id']=$_POST['id'];
		$data['sdt_name']=$_POST['name'];
		$data['sdt_home']=$_POST['home'];
		$data['sdt_phone']=$_POST['phone'];
		$data['sdt_birthday']=$_POST['birthday'];
		$data['sdt_sex']=$_POST['sex'];
		$data['sdt_family_hone']=$_POST['familyPhone'];
		$data['sdt_nickname']=$_POST['nickname'];
		$data['sdt_photo']=$_POST['photo'];
		$data['sdt_readme']=$_POST['readme'];
		$u['user_id']=$data['sdt_id'];
		$u['user_pwd']=date('YmdHis');
		$u['user_register_time']=date('Y-m-d H:i:s');
		$u['user_level']=2;
		
		//$student=M('student');
		//$result=$student->add($data);
		
		print_r($u);
		
		$user=M('user');
		$result=$user->add($u);
		
		if($result){
			echo '{state:"ok"}';
		}else{
			echo '{state:"error"}';
		}
	}
}

